<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>键盘事件</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="root">
    <h2>来{{name}}学习啦</h2>
    <!-- .enter表示enter键的别名-->
    <input type="text" placeholder="按下回车提示输入" @keyup.enter="showInfor">
</div>
<script>
    Vue.config.productionTip = false;
    // 定义一个按键的别名
    Vue.config.keyCodes.huiche = 13;
    new Vue({
        el: '#root',
        data: {
            name: '西北工业大学'
        },
        methods: {
            showInfor(event) {
                console.log(event.key, event.keyCode);
                console.log(event.target.value)
            }
        }
    });
</script>
</body>
</html>